<?php
/**
 * Created by PhpStorm.
 * User: zouhua
 * Date: 2017/6/19
 * Time: 17:56
 */

namespace app\actions;


use app\models\Comment;
use app\models\Like;
use yii\db\ActiveQuery;

class PostCommentAction extends UserList {

    public function beforeRun() {
        if (!parent::beforeRun()) {
            return FALSE;
        }

        $uid = $this->controller->getLikeId();
        $id = $this->getParam('id');
        $this->where = ['own' => Comment::OWN_POST, 'own_id' => $id, 'status' => Comment::STATUS_YES];
        $this->with = ['user', 'like' => function(ActiveQuery $query) use ($uid){
            $query->andWhere(['uid' => $uid, 'own' => Like::OWN_COMMENT]);
        }];

        return TRUE;
    }
}